package com.talos.framework.common.pojo;


import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

@Data
@NoArgsConstructor
public class PageInfo<T> implements Serializable {

    private static final long serialVersionUID = 1L;

    @Schema(description = "数据", requiredMode = Schema.RequiredMode.REQUIRED)
    private List<T> data;

    @Schema(description = "当前页数")
    private long pageNum;

    @Schema(description = "当前条数")
    private long pageSize;

    @Schema(description = "总条数")
    private long totalSize;

    public PageInfo(QueryDTO dto) {
        this.data = new ArrayList<>();

        this.pageNum = dto.getPageNum();

        this.pageSize = dto.getPageSize();

        this.totalSize = 0L;
    }
    public Boolean hasMore() {
        return this.pageNum < Math.ceil(1.0 * this.getTotalSize() / this.getPageSize());
    }
}
